﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using FeaturesBlog.Models.Interfaces;


namespace FeaturesBlog.Models.Repositories
{
    public class UserRepository : IUserRepository
    {
        #region Variables
        private MyFeaturesBlogClassesDataContext _context;
        #endregion

        #region Methods
        public UserRepository(MyFeaturesBlogClassesDataContext c)
        {
            _context = c;
        }
        public User GetUser(decimal id)
        {
            return _context.Users.SingleOrDefault(u => u.UserId == id);
        }
        public User GetUser(string name)
        {
            return _context.Users.SingleOrDefault(u => u.UserName == name);
        }
        public bool ValidateUser(string userName, string password)
        {
            User user = _context.Users.SingleOrDefault(u => u.UserName == userName && u.Password == password);
            return user != null;
        }
        #endregion
    }
}
